﻿using System;
using EntitiesTM;
using Business;

namespace TimeWork
{
    public partial class CreateClient : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["email"] == null)
            {
                Response.Redirect("http://"+Request.Url.Authority+"/Login.aspx");
            }
        }

        protected void btnCreate_Click(object sender, EventArgs e)
        {
            

            lblClientName.Text = String.Empty;
            string clientName = txtClientName.Text.Trim();
            

            txtClientName.CssClass = "input-error";
            // Kiem tra khac rong
            if (!clientName.Equals(""))
            {
                txtClientName.CssClass = "valid";
            }


            if (!clientName.Equals(""))
            {
                EnClient client = new EnClient();
                client.clientName = clientName;
                client.url = txtURL.Text.Trim();
                client.clientDes = txtDescription.Text.Trim();
                client.clientAddress = txtAddress.Text.Trim();
                client.nameAlt = txtNameAlt.Text.Trim();
                client.contactPerson = txtNameContact.Text.Trim();
                client.email = txtEmail.Text.Trim();
                client.phone = txtPhone.Text.Trim();
                client.fax = txtFax.Text.Trim();


                BuClient.insClient(client, Session["companyid"].ToString());
                Response.Redirect("~/time/admin/Client.aspx");
                    
            }
                
            
        }
    }
}